package com.travel.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.travel.dao.BaseDAO;
import com.travel.service.BaseService;

import java.util.List;

public abstract class BaseServiceImpl<T> implements BaseService<T> {

    public abstract BaseDAO getBaseDAO();


    @Override
    public void add(T t) {
        getBaseDAO().add(t);
    }

    @Override
    public void update(T t) {
        getBaseDAO().update(t);
    }

    @Override
    public void delete(Integer id) {
        getBaseDAO().delete(id);
    }

    @Override
    public List<T> getList(Object obj) {
        return getBaseDAO().getList(obj);
    }

    @Override
    public PageInfo<T> getList(Object obj, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<T> list = getBaseDAO().getList(obj);
        return new PageInfo<>(list);
    }
}
